package me.wangcai.trafficpoliceai.model.request;

import lombok.Getter;
import me.wangcai.trafficpoliceai.enums.PermissionEnum;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@Getter
public class EditUserRequest extends TokenRequest{
    private int id;
    private String password;
    private String carId;
    private String mail;
    private PermissionEnum permission;

    public void setPermission(boolean permission) {
        if(permission){
            this.permission = PermissionEnum.ADMIN;
        }else {
            this.permission = PermissionEnum.USER;
        }
    }

    public void setPassword(String password) {
        if(password == null) return;
        this.password = new BCryptPasswordEncoder().encode(password);
    }
}
